<?php
/*
    GUMUD is Extensible Web-based Multi-User Dungeon Software.

    Copyright (C) 2013  White Rabbit

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//MySQL Query Database
function myquery($query) {
	mysql_connect(dbhost, dbuser, dbpass);
	mysql_select_db(dbname);
	$result = mysql_query($query);
	if (!mysql_errno() && @mysql_num_rows($result) > 0) {
}
else {
$result="not";
}
	mysql_close();
	return $result;
}
// MySQL Num Rows
function myrows($result) {
	$rows = @mysql_num_rows($result);
	return $rows;
}
// MySQL fetch array
function myarray($result) {
	$array = mysql_fetch_array($result);
	return $array;
}
// MySQL escape string
function myescape($query) {
	$escape = mysql_escape_string($query);
	return $escape;
}
//Initilize Session
function initSession($session) {
	if (!isset($session['initiated'])) {
		session_regenerate_id();
		$session['initiated'] = true;
	}
	return $session;
}
//Agent Session
function agentSession($session,$agent) {
	$fingerprint = md5($agent . publicsecret);
	if (isset($session['HTTP_USER_AGENT'])) {
		if ($session['HTTP_USER_AGENT'] != $fingerprint) {
			die();
			exit;
		}
	} else {
		$session['HTTP_USER_AGENT'] = $fingerprint;
	}
	return $session;
}
function gen_uuid() {
    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        // 32 bits for "time_low"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),

        // 16 bits for "time_mid"
        mt_rand( 0, 0xffff ),

        // 16 bits for "time_hi_and_version",
        // four most significant bits holds version number 4
        mt_rand( 0, 0x0fff ) | 0x4000,

        // 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low",
        // two most significant bits holds zero and one for variant DCE1.1
        mt_rand( 0, 0x3fff ) | 0x8000,

        // 48 bits for "node"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
    );
}
function genderBender($target,$db) {
if ($target == "she") {
if($db == "male") {
	return "he";
	}
	elseif($db == "female") {
	return "she";
	}
	elseif($db == "unisex") {
	return "the person";
	}
}
elseif ($target == "hers") {
if($db == "male") {
	return "his";
	}
	elseif($db == "female") {
	return "hers";
	}
	elseif($db == "unisex") {
	return "their";
	}
}
elseif ($target == "her") {
if($db == "male") {
	return "his";
	}
	elseif($db == "female") {
	return "her";
	}
	elseif($db == "unisex") {
	return "their";
	}
}
elseif ($target == "woman") {
if($db == "male") {
	return "man";
	}
	elseif($db == "female") {
	return "woman";
	}
	elseif($db == "unisex") {
	return "person";
	}
}
elseif ($target == "women") {
	if($db == "male") {
	return "men";
	}
	elseif($db == "female") {
	return "women";
	}
	elseif($db == "unisex") {
	return "people";
	}
}
}
function splitData($foo) {
if(preg_match("/(\w|\W)*(~)+(\w|\W)*/",$foo)) {
	$faa = explode("~",$foo);
	}
	else { $faa[0] = $foo;}
	return $faa;
}
function gridGod($uuid) {
$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$uuid."' AND `userLevel` = 'staff-gridgod' LIMIT 1");
if ($result1 != "not") { return TRUE; }
else { return FALSE; }
}
function admin($uuid) {
$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$uuid."' AND `userLevel` = 'staff-admin' LIMIT 1");
if ($result1 != "not") { return TRUE; }
else { return FALSE; }
}
function requestFilter($get) {
$output = "";
// USER FUNCTIONS
	if ($get['request'] == "validateuser") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		if (!preg_match("/(\w)+/",$get['passhash'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' AND `passhash` = '".$get['passhash']."' LIMIT 1");
		if ($result1 != "not") {
		$output = $output."validated";
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getClasses") {
		if($get['valtype'] == "equal") {
		$result1 = myquery("SELECT * FROM `".dbprfx."char-classes` WHERE `classCost` = '".$get['value']."'");
		$x = 1;
		$str1 = "";
		while($x <= myrows($result1)) {
		$array1 = myarray($result1);
		$str1 = $str1.$array1['classUUID']."|".$array1['className'];
		if ($x != myrows($result1)) {
		$str1 = $str1."~";
		}
		$x++;
		}
		}
		elseif($get['valtype'] == "greater") {
		$result1 = myquery("SELECT * FROM `".dbprfx."char-classes` WHERE `classCost` > '".$get['value']."'");
		$x = 1;
		$str1 = "";
		while($x <= myrows($result1)) {
		$array1 = myarray($result1);
		$str1 = $str1.$array1['classUUID']."|".$array1['className'];
		if ($x != myrows($result1)) {
		$str1 = $str1."~";
		}
		$x++;
		}
		}
		elseif($get['valtype'] == "lesser") {
		$result1 = myquery("SELECT * FROM `".dbprfx."char-classes` WHERE `classCost` < '".$get['value']."'");
		$x = 1;
		$str1 = "";
		while($x <= myrows($result1)) {
		$array1 = myarray($result1);
		$str1 = $str1.$array1['classUUID']."|".$array1['className'];
		if ($x != myrows($result1)) {
		$str1 = $str1."~";
		}
		$x++;
		}
		}
		$output = $str1;
	}
	if ($get['request'] == "getGuilds") {
	$result1 = myquery("SELECT * FROM `".dbprfx."guild` WHERE `guildEnrollment` = 'open'");
		$x = 1;
		$str1 = "";
		while($x <= myrows($result1)) {
		$array1 = myarray($result1);
		$str1 = $str1.$array1['guildUUID']."|".$array1['guildName'];
		if ($x != myrows($result1)) {
		$str1 = $str1."~";
		}
		$x++;
		}
		$output = $str1;
	}
	if ($get['request'] == "createUser") {

		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."' LIMIT 1");
		if ($result1 != "not") {
		$output = $output."fail";
		}
		else {
		$var1 = gen_uuid();
		$resultdf = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `defaultRegion` = 'yes' LIMIT 1");
		$arraydf = myarray($resultdf);
		
		$resultSdf = myquery("INSERT INTO `".dbprfx."grid-users` (`UUID`,`avatarFirst`,`avatarLast`,`passhash`,`regionLoc`,`userLevel`,`email`,`registerIP`,`currentIP`,`deprecateTrigger`,`characterClass`, `expPoints`,`level`,`gender`) values ('".$var1."','".$get['firstname']."','".$get['lastname']."','".$get['password']."','".$arraydf['regionUUID']."','user-unvalidated','".myescape(urldecode($get['email']))."','".$get['ip']."','".$get['ip']."','no','".$get['group']."','0','1','".$get['gender']."')");
		$resultGdf = myquery("INSERT INTO `".dbprfx."guild-members` (`guildMemberUUID`,`guildUUID`,`deprecateTrigger`) VALUES ('".$var1."','".$get['guild']."','no')");
		setStockBody($var1,$get['gender']);
		file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=setUserHP&uuid=".$var1."&headhp=".defheadhp."&chesthp=".defchesthp."&abdomenhp=".defabdomenhp."&lleghp=".deflleghp."&rleghp=".defrleghp."&larmhp=".deflarmhp."&rarmhp=".defrarmhp."&lfoothp=".deflfoothp."&rfoothp=".defrfoothp."&rhandhp=".defrhandhp."&lhandhp=".deflhandhp);		
		if(statDetermination == "SET") {
		file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=setUserStats&strength=".defStength."&stamina=".defStamina."&dexterity=".defDexterity."&intelligence=".defIntelligence."&education=".defEducation."&willpower=".defWillpower."&uuid=".$var1);
		}
		elseif (statDetermination == "RANDOM") {
		file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=setUserStats&strength=".rand(defRNGStrengthMIN,defRNGStrengthMAX)."&stamina=".rand(defRNGStaminaMIN,defRNGStaminaMAX)."&dexterity=".rand(defRNGDexterityMIN,defRNGDexterityMAX)."&intelligence=".rand(defRNGIntelligenceMIN,defRNGIntelligenceMAX)."&education=".rand(defRNGEducationMIN,defRNGEducationMAX)."&willpower=".rand(defRNGWillpowerMIN,defRNGWillpowerMAX)."&uuid=".$var1);
		}
		file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=SETxchangeValues&uuid=".$var1."&lex=".defExchangeLex."&wallet=".defExchangeWallet."&gold=".defExchangeGold."&mana=".defExchangeMana);

file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=setInitialClothing&uuid=".$var1."&outfit=".urlencode($get['outfit']));
		// myquery("INSERT INTO `".dbprfx."avatar-attach-layers` (`userUUID`) VALUES ('".$var1."')");
		$result2 = myquery("INSERT INTO `".dbprfx."local-chat-update-time` (`chattime`,`userUUID`) VALUES ('".time()."','".$var1."')");
		$output = $output."success";
		}
	}
	if ($get['request'] == "setInitialClothing") {
	$result1 = myquery("SELECT * FROM `".dbprfx."default-clothing` WHERE `outfit` = '".urldecode($get['outfit'])."' ORDER BY `clothingUUID` ASC");
	$resultY = myquery("SELECT * FROM `".dbprfx."default-clothing` WHERE `outfit` = '".urldecode($get['outfit'])."' ORDER BY `clothingUUID` ASC");
	$x = 1;
	$arrayY = myarray($resultY);
	$oldUUID = "";
	while ($x <= myrows($result1)) {
	$str1 = gen_UUID();
	$array1 = myarray($result1);
$array1['clothingUUID'];
	$CurrentUUID = $array1['clothingUUID'];
	if ($CurrentUUID != $oldUUID) {
	myquery("INSERT INTO `".dbprfx."inventory` (`objectUUID`,`objectInstanceUUID`,`copySwitch`,`modSwitch`,`transferSwitch`,`copyNextSwitch`,`modNextSwitch`,`transferNextSwitch`,`ownerUUID`,`objectName`) VALUES ('".$str1."','".$str1."','yes','yes','yes','yes','yes','yes','".$get['uuid']."','".$array1['objectName']."')");
	
	myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$str1."','".$get['uuid']."','".$array1['objectTYPE']."','".$array1['objectName']."','".$array1['defObjectState']."','".$array1['objectOrder']."','".$array1['objectLayer']."','yes')");
	}
	myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','".$array1['stateName']."','".$array1['stateViewSuccess']."','".$array1['stateViewFailure']."','".$array1['stateDetailViewSuccess']."','".$array1['stateDetailViewFailure']."','".$array1['statePassThreshold']."','".$array1['statePassTriggers']."','".$array1['stateFailTriggers']."')");
	$oldUUID = $CurrentUUID;
	$x++;
	}
	}
if ($get['request'] == "getDefOutfits") {
$result1 = myquery("SELECT * FROM `".dbprfx."default-clothing` ORDER BY `outfit` ASC");
$x = 1;
$tempold = "";
while($x <= myrows($result1)) {
$array1 = myarray($result1);
$tempnew = $array1['outfit'];
if ($tempnew != $tempold) { $tempold = $tempnew; $output = $output.$tempnew; if($x != myrows($result1)) { $output = $output."~";} }
$x++;
}
}
	if ($get['request'] == "getUserLastTimeLocalChat") {

		$result1 = myquery("SELECT * FROM `".dbprfx."local-chat-update-time` WHERE `userUUID` = '".$get['uuid']."' LIMIT 1");
		
		$array = myarray($result1);
		$output = $array['chattime'];
	}
	if ($get['request'] == "insertUserLastTimeLocalChat") {

		$result2 = myquery("INSERT INTO `".dbprfx."local-chat-update-time` (`chattime`,`userUUID`) VALUES ('".time()."','".$get['uuid']."')");
		$output = "success";
	}
	if ($get['request'] == "updateUserLastTimeLocalChat") {
		
		$result3 = myquery("UPDATE `".dbprfx."local-chat-update-time` SET `chattime` = '".$get['time']."' WHERE `userUUID` = '".$get['uuid']."'");
		$output = "success";
	}
	if ($get['request'] == "updateHeartbeat") {
	$result1 = myquery("SELECT * FROM `".dbprfx."avatar-heartbeat` WHERE `userUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$result1 = myquery("UPDATE `".dbprfx."avatar-heartbeat` SET `heartbeatTime` = '".time()."' WHERE `userUUID` = '".$get['uuid']."'");
		}
		else {
		$result2 = myquery("INSERT INTO `".dbprfx."avatar-heartbeat` (`heartbeatTime`,`userUUID`) VALUES ('".time()."','".$get['uuid']."')");
		}
		$output = "success";
	}
	if ($get['request'] == "getHeartbeat") {
	$result1 = myquery("SELECT * FROM `".dbprfx."avatar-heartbeat` WHERE `userUUID` = '".$get['uuid']."' LIMIT 1");
	$array = myarray($result1);
		$output = $array['heartbeatTime'];
	}
	if ($get['request'] == "getuser") {
		
		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $array1['UUID'];
		}
		else {
		$output = "fail";
		}
	}
	if ($get['request'] == "getUserByEmail") {
		
		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `email` = '".urldecode($get['value'])."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $array1['UUID'];
		}
		else {
		$output = "fail";
		}
	}
	if ($get['request'] == "getUserLevel") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['userLevel'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getUserRegionLoc") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['regionLoc'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getUserEmail") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		if (!preg_match("/(\w)+/",$get['passhash'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' AND `passhash` = '".$get['passhash']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['email'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getUserInfo") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['avatarFirst']."~".$array1['avatarLast']."~".$array1['characterClass']."~".$array1['expPoints']."~".$array1['level']."~".$array1['lang']."~".$array1['emoticons'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getInventory") {
		if (!preg_match("/(\w)+/",$get['firstname'])) { die(); exit(); }
		if (!preg_match("/(\w)+/",$get['lastname'])) { die(); exit(); }
		$output = "<ul>";
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$array1['UUID']."'");
		$x = 1;
		while($x <= myrows($result2)) {
		$array2 = myarray($result2);
		$result3 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `objectUUID` = '".$array2['objectInstanceUUID']."'");
		$array3 = myarray($result3);
		$output = $output."<li>".$array3['objectName'];
		$x++;
		}
		$output = $output."</ul>";
		}
		else {
		$output = $output."fail";
		}
	}
if ($get['request'] == "getSettings") {
		if (!preg_match("/(\w)+/",$get['firstname'])) { die(); exit(); }
		if (!preg_match("/(\w)+/",$get['lastname'])) { die(); exit(); }
		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."' LIMIT 1");
		if($result1 != "not") {
		$array1 = myarray($result1);
$output = "<ul>";
		$output = $output."<li>Emoticons: ";
		if($array1['emoticons'] == "yes") {

		$output = $output."ON (<a href='archerToggleEmoticons.php' target='archer'>switch off</a>)";
}
else {
		$output = $output."OFF (<a href='archerToggleEmoticons.php' target='archer'>switch on</a>)";
}
		}
		else {
				$output = $output."fail";
				}
}
if ($get['request'] == "setSettings") {
		if (!preg_match("/(\w)+/",$get['firstname'])) { die(); exit(); }
		if (!preg_match("/(\w)+/",$get['lastname'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."' LIMIT 1");
		if($result1 != "not") {
$array1 = myarray($result1);
	if($array1['emoticons'] == "yes") {$value = "no";} else {$value = "yes";}
		$result1 = myquery("UPDATE `".dbprfx."grid-users` SET `".$get['setting']."` = '".$value."' WHERE `avatarFirst` = '".$get['firstname']."' AND `avatarLast` = '".$get['lastname']."'");
}

}
	if ($get['request'] == "getInventoryInstanceUUID") {
	$result3 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['data']))."'");
		if($result3 != "not") {
		$array3 = myarray($result3);
		$output = $array3['objectInstanceUUID'];
		}
		else {
		$output = "fail";
		}
	}
	if ($get['request'] == "editInventoryObjectType") {
		
		 
			 
					
		$str7 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getInventoryInstanceUUID&uuid=".$get['uuid']."&data=".urlencode($get['data']));
		
		
		$var6 = urldecode($get['type']);
		
		$str6 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=updateObjectType&uuid=".$str7."&data=".urlencode($var6));
			if($str6 == "success") {
			$output = "Object type successfully updated.";
}
else {
$output = "Whoops we can't seem to update the item's type at this time!";
}			
				 
			 
		
	 
	
	}
	if ($get['request'] == "getHeartbeatUsers") {
	$itx['com-inner'][3] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getuser&firstname=".$get['firstname']."&lastname=".$get['lastname']);
		$itx['com-inner'][4] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getUserRegionLoc&uuid=".$itx['com-inner'][3]);
		$itx['com-inner'][5] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getRegionData&uuid=".$itx['com-inner'][4]);
		
		$array1 = splitData($itx['com-inner'][5]);
		$array2 = splitData(file_get_contents("http://".$array1[3]."/index.php?scripthandshakeID=".scripthandshakeID."&request=getLocalLoc&uuid=".$itx['com-inner'][3]));
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `regionLoc` = '".$itx['com-inner'][4]."'");
		$x = 1;
		$count = 0;
		
		$inventory = "You see ";
		$listpunc = 1;
		while($x <= myrows($result1)) {
		$joke = 1;
		$array4 = myarray($result1);
		$array3 = splitData(file_get_contents("http://".$array1[3]."/index.php?scripthandshakeID=".scripthandshakeID."&request=getLocalLoc&uuid=".$array4['UUID']));
		if(($array3[0] == $array2[0]) and ($array3[1] == $array2[1])) {
		$result2 = myquery("SELECT * FROM `".dbprfx."avatar-heartbeat` WHERE `userUUID` = '".trim($array4['UUID'])."'");
			
			$array5 = myarray($result2);
			if($array5[1] > (time() - 100)) {
			$count++;
			if($array5[0] == $itx['com-inner'][3]) {
			
			}
			else {
			$inventory = $inventory.$array4['avatarFirst']." ".$array4['avatarLast']."::".$listpunc."::";
			$listpunc++;		
			}
			}
			
		}
		$x++;
		}
		$inventory = $inventory." here.";
		if ($count == 1) {
		$impinventory = "You are the only one here.";
		$inventory = "You see only yourself here.";
		}
		elseif ($count == 2) {
		$impinventory = "There are two people here.";
		$inventory = str_replace("::1::","",$inventory);
		}
		elseif ($count == 3) {
		$impinventory = "There are three people here.";
		$inventory = str_replace("::1::"," and ",$inventory);
		}
		else {
		$impinventory = "There are ".$count." people here.";
		$y = 1;
		while($y <= ($listpunc - 1)) {
		if($y != ($listpunc - 1)) {
		$inventory = str_replace("::".$y."::",", ",$inventory);
		}
		else {
		$inventory = str_replace("::".$y."::"," and ",$inventory);
		}
		$y++;
		}
		}
		$output = $count."~".$impinventory."~".$inventory;
	} 
	if ($get['request'] == "getUserStats") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."avatar-hp` WHERE `avatarUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$x = 0;
		while (isset($array1[$x])) {
		$output = $output.$array1[$x];
		if(isset($array1[$x+1])) { $output = $output."|"; }
		$x++;
		}
		}
		$output = $output."|";
		$result1 = myquery("SELECT * FROM `".dbprfx."avatar-attributes` WHERE `avatarUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$x = 0;
		while (isset($array1[$x])) {
		$output = $output.$array1[$x];
		if(isset($array1[$x+1])) { $output = $output."|"; }
		$x++;
		}
		}
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
		$array2 = myarray($result1);
		$output = $output."|".$array2['expPoints'];
	}
	if($get['request'] == "setUserStats") {
	$result1 = myquery("SELECT * FROM `".dbprfx."avatar-attributes` WHERE `avatarUUID` = '".$get['uuid']."' LIMIT 1");
	if ($result1 != "not") {
		myquery("UPDATE `".dbprfx."avatar-attributes` SET `strength` = '".$get['strength']."',`stamina` = '".$get['stamina']."',`dexterity` = '".$get['dexterity']."',`intelligence` = '".$get['intelligence']."',`education` = '".$get['education']."', `willpower` = '".$get['willpower']."' WHERE `avatarUUID` = '".$get['uuid']."'");
	}
	else {
		myquery("INSERT INTO `".dbprfx."avatar-attributes` (`avatarUUID`,`strength`,`stamina`,`dexterity`,`intelligence`,`education`,`willpower`) VALUES ('".$get['uuid']."','".$get['strength']."','".$get['stamina']."','".$get['dexterity']."','".$get['intelligence']."','".$get['education']."','".$get['willpower']."')");
	}
	$output = "success";
	}
if($get['request'] == "setUserHP") {
	$result1 = myquery("SELECT * FROM `".dbprfx."avatar-hp` WHERE `avatarUUID` = '".$get['uuid']."' LIMIT 1");
	if ($result1 != "not") {
		myquery("UPDATE `".dbprfx."avatar-hp` SET `headHP` ='".$get['headhp']."',`chestHP` ='".$get['chesthp']."',`abdomenHP`='".$get['abdomenhp']."',`LarmHP`='".$get['larmhp']."',`RarmHP`='".$get['rarmhp']."',`LlegHP`='".$get['lleghp']."',`RlegHP`='".$get['rleghp']."',`LhandHP`='".$get['lhandhp']."',`RhandHP`='".$get['rhandhp']."',`LfootHP`='".$get['lfoothp']."',`RfootHP`= '".$get['rfoothp']."' WHERE `avatarUUID` = '".$get['uuid']."'");
	}
	else {
		myquery("INSERT INTO `".dbprfx."avatar-hp` (`avatarUUID`,`headHP`,`chestHP`,`abdomenHP`,`LarmHP`,`RarmHP`,`LlegHP`,`RlegHP`,`LhandHP`,`RhandHP`,`LfootHP`,`RfootHP`,`headHPnorm`,`chestHPnorm`,`abdomenHPnorm`,`LarmHPnorm`,`RarmHPnorm`,`LlegHPnorm`,`RlegHPnorm`,`LhandHPnorm`,`RhandHPnorm`,`LfootHPnorm`,`RfootHPnorm`) VALUES ('".$get['uuid']."','".$get['headhp']."','".$get['chesthp']."','".$get['abdomenhp']."','".$get['larmhp']."','".$get['rarmhp']."','".$get['lleghp']."','".$get['rleghp']."','".$get['lhandhp']."','".$get['rhandhp']."','".$get['lfoothp']."','".$get['rfoothp']."','".$get['headhp']."','".$get['chesthp']."','".$get['abdomenhp']."','".$get['larmhp']."','".$get['rarmhp']."','".$get['lleghp']."','".$get['rleghp']."','".$get['lhandhp']."','".$get['rhandhp']."','".$get['lfoothp']."','".$get['rfoothp']."')");
	}
	$output = "success";
	}
// REGION FUNCTIONS
	if ($get['request'] == "getRegionData") {
		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `regionUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['regionUUID']."~".$array1['ownerUUID']."~".$array1['groupUUID']."~".$array1['serverURL']."~".$array1['regionName']."~".$array1['regionX']."~".$array1['regionY']."~".$array1['deprecateTrigger'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "teleportAvatar") {
		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `regionName` = '".trim(myescape(urldecode($get['data'])))."' LIMIT 1");
		if ($result1 != "not") {
		
		$array1 = myarray($result1);
		$result2 = myquery("UPDATE `".dbprfx."grid-users` SET `regionLoc` = '".$array1['regionUUID']."' WHERE `UUID` = '".$get['uuid']."'");
		$itx['com-inner'][5] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getRegionData&uuid=".$array1['regionUUID']);
		$array2 = splitData($itx['com-inner'][5]);
		$itx['com-inner'][6] = file_get_contents("http://".$array2[3]."/index.php?scripthandshakeID=".scripthandshakeID."&request=sceneViewDefaultLookup&uuid=".$array1['regionUUID']);
		$array3 = splitData($itx['com-inner'][6]);
		$itx['com-inner'][6] = file_get_contents("http://".$array2[3]."/index.php?scripthandshakeID=".scripthandshakeID."&request=putLocalLoc&uuid=".$get['uuid']."&localX=".$array3[0]."&localY=".$array3[1]);
		$output = $output."teleport successful";
		}
		else {
		$output = $output."teleport failed";
		}
	}
	if ($get['request'] == "getRegionUUID") {
		if (!preg_match("/(\w|\+)+/",$get['regionname'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `regionName` = '".str_replace("+"," ",$get['regionname'])."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['regionUUID'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getRegionOwnerUUID") {

		
		$result1 = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `regionUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $array1['ownerUUID'];
		}
		else {
		$output = "fail";
		}
	}
// Character CLasses
	if ($get['request'] == "requestCharClassName") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."char-classes` WHERE `classUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['className'];
		}
		else {
		$output = $output."fail";
		}
	}
// Exchange
	if ($get['request'] == "GETxchangeLex") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['exchangeLexical'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "DEDUCTxchangeLex") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		
		$array1 = myarray($result1);
			if (($array1['exchangeLexical'] - $get['amount']) > 0) {
			$var1 = $array1['exchangeLexical'] - $get['amount'];
			$result2 = myquery("UPDATE `".dbprfx."exchange-balance` SET `exchangeLexical` = '".$var1."' WHERE `exchangeUserUUID` = '".$get['uuid']."'");
			$output = $var1;
			}
			else {
			$output = "NSF";
			}
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "GETxchangeWallet") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['exchangeWallet'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "SETxchangeWallet") {
	if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("UPDATE `".dbprfx."exchange-balance` SET `exchangeWallet` = '".$get['amount']."' WHERE `exchangeUserUUID` = '".$get['uuid']."'");
	}
	if ($get['request'] == "GETxchangeGold") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['exchangeGold'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "GETxchangeMana") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['exchangeMana'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "getExchange") {
$str1 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getuser&firstname=".$get['firstname']."&lastname=".$get['lastname']);
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$str1."' LIMIT 1");
		if($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output."<li>::wallet::: ".$array1['exchangeWallet']." (<a href='index.php?com=exchange&action=walletpurchase&ob1=wallet'>::walletx::</a>)";
$output = $output."<li>::gold::: ".$array1['exchangeGold']." (<a href='index.php?com=exchange&action=walletpurchase&ob1=gold'>::goldx::</a>)";
$output = $output."<li>::lexical::: ".$array1['exchangeLexical']." (<a href='index.php?com=exchange&action=walletpurchase&ob1=lexical'>::lexicalx::</a>)";
$output = $output."<li>::mana::: ".$array1['exchangeMana']." (<a href='index.php?com=exchange&action=walletpurchase&ob1=mana'>::manax::</a>)";
		}

	}
	if ($get['request'] == "SETxchangeValues") {
	if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."exchange-balance` WHERE `exchangeUserUUID` = '".$get['uuid']."' LIMIT 1");
		if ($result1 != "not") {
		myquery("UPDATE `".dbprfx."exchange-balance` SET `exchangeLexical` = '".$get['lex']."', `exchangeWallet` = '".$get['wallet']."',`exchangeGold` = '".$get['gold']."',`exchangeMana` = '".$get['mana']."' WHERE `exchangeUserUUID` = '".$get['uuid']."'");
}
else {
		myquery("INSERT INTO `".dbprfx."exchange-balance` (`exchangeUserUUID`,`exchangeLexical`,`exchangeWallet`,`exchangeGold`,`exchangeMana`) VALUES ('".$get['uuid']."','".$get['lex']."','".$get['wallet']."','".$get['gold']."','".$get['mana']."')");
}
}
//GUILD
	if ($get['request'] == "requestGuildMem") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."guild-members` WHERE `guildMemberUUID` = '".$get['uuid']."' AND `deprecateTrigger` = 'no' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['guildUUID'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "requestGuildName") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."guild` WHERE `guildUUID` = '".$get['uuid']."'  AND `deprecateTrigger` = 'no' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['guildName'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "requestGuildDescription") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."guild` WHERE `guildUUID` = '".$get['uuid']."'  AND `deprecateTrigger` = 'no' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['guildDescription'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "requestGuildownerUUID") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("SELECT * FROM `".dbprfx."guild` WHERE `guildUUID` = '".$get['uuid']."'  AND `deprecateTrigger` = 'no' LIMIT 1");
		if ($result1 != "not") {
		$array1 = myarray($result1);
		$output = $output.$array1['guildOwnerUUID'];
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "initObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectLex`,`objectDetailLex`,`objectName`,`objectState`) values ('".$get['objectUUID']."','".$get['uuid']."','lexical object','a freshly created object','a freshly created object','".myescape(urldecode($get['object']))."','VIEW')");
		if ($result1 != "not") {
		$output = $output."success";
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "viewObject") {
	
		$result1 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `objectUUID` = '".$get['objectUUID']."'");
		$array = myarray($result1);
		$result2 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$get['objectUUID']."' AND `stateName` = '".$array['objectState']."' LIMIT 1");
		$array2 = myarray($result2);
		$array4 = splitdata($array2['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($get['objectUUID'],$get['personuuid'],$array5[0],$array5[1]);
		$xxx=$xxx+2;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array2['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($get['objectUUID'],$get['personuuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		
		$text = $array2['stateViewSuccess'];
		}
		else {
			$array6 = splitdata($array2['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($get['objectUUID'],$get['personuuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array2['stateViewFailure'];
		}
		$output = $text;
		
		
		}
	
	// CREATE REGION
	if ($get['request'] == "createRegion") {
		$result1 = myquery("SELECT * FROM `".dbprfx."region` WHERE `regionName` = '".$get['data']."' LIMIT 1");
		if($result1 != "not") {
			$output = "region creation failed; region name exists already on the map!";
		}
		else {
			$result2 = myquery("SELECT * FROM `".dbprfx."grid-regions` WHERE `regionX` = '".$get['regionX']."' AND `regionY` = '".$get['regionY']."' LIMIT 1");
			if($result1 != "not") {
			$output = "region creation failed; region coordinates exist already on the map!";
			}
			 elseif (($var1['localX'] > regionMaxX) or ($var1['localY'] > regionMaxY)) { 
	 $output = "Region coordinates are beyond map boundaries";
	 }
	 elseif (($var1['localX'] < 0) or ($var1['localY'] < 0)) { 
	 $output = "Region coordinates are beyond map boundaries";
	 }
			else {
			if(RegionRegistrationType == "GRIDGOD") { if(gridGOD($get['uuid'])) {$cancreate = TRUE;}}
			if(RegionRegistrationType == "ADMIN") { if((gridGOD($get['uuid'])) or (admin($get['uuid']))) {$cancreate = TRUE;}}
			if(RegionRegistrationType == "LEXPOINTS") {$cancreate = TRUE; $deductlexpoints = TRUE;}
			if(RegionRegistrationType == "DISABLED") { if(gridGOD($get['uuid'])) {$cancreate = FALSE;}}
			if($cancreate) {
			$var2 = "OKAY";
			if($deductlexpoints) {$var2 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=DEDUCTxchangeLex&uuid=".$get['uuid']."&amount=".RegionCost);}
			if ($var2 != "NSF") {
			$var1 = gen_uuid();
			$result4 = myquery("SELECT * FROM `".dbprfx."servers` WHERE `active` = 'YES' ORDER BY `lastAssignTime` ASC LIMIT 1");
			$array3 = myarray($result4);
			$result5 = myquery("UPDATE `".dbprfx."servers` SET `lastAssignTime` = '".time()."' WHERE `serverURL` = '".$array3['serverURL']."'");
			$result3 = myquery("INSERT INTO `".dbprfx."grid-regions` (`regionUUID`,`ownerUUID`,`serverURL`,`regionName`,`regionX`,`regionY`) VALUES ('".$var1."','".$get['uuid']."','".$array3['serverURL']."','".$get['data']."','".$get['regionX']."','".$get['regionY']."')");
			file_get_contents("http://".$array3['serverURL']."/index.php?scripthandshakeID=".scripthandshakeID."&request=initRegion&uuid=".$var1."&owneruuid=".$get['uuid']."&localX=100&localY=100");
			$output = "region successfully added.";
			}
			else {
			$output = "region could not be created; You do not have enough LexPoints.";
			}
			}
			else {
			$output = "region could not be added;You do not have authorization.";
			}
			}
		}
		
		
	}
	if ($get['request'] == "setAvatarGender") {
	$result4 = myquery("UPDATE `".dbprfx."grid-users` SET `gender` = '".$get['gender']."' WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
	$output = "success";
	}
	if ($get['request'] == "viewAvatar") {
	$result5 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
	$arrayG = myarray($result5);
	$resultS = myquery("SELECT * FROM `".dbprfx."avatar-states` WHERE `avatarUUID` = '".$get['uuid']."' AND `stateName` = '".$arrayG['avatarState']."' LIMIT 1");
	$arrayS = myarray($resultS);
	$array4A = splitdata($arrayS['statePassThreshold']);
	$xxx = 0;
		
		while(isset($array4A[$xxx])) {
		$array5A = explode("|",$array4A[$xxx]);
		$pass = stateAvatarPassThreshold($get['uuid'],$array5[0],$array5A[1]);
		$xxx=$xxx+2;
		}
		unset($array5A);
		if($pass) {
			$array6A = splitdata($arrayS['statePassTriggers']);
			$xxx = 0;
			while(isset($array6A[$xxx])) {
			$array7A = explode("|",$array6A[$xxx]);
			$trigger = stateAvatarTriggers($get['uuid'],$array7A[0],$array7A[1]);
			$xxx++;
			}
		
		$textA = $arrayS['stateViewSuccess'];
		}
		else {
			$array6A = splitdata($arrayS['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6A[$xxx])) {
			$array7A = explode("|",$array6A[$xxx]);
			$trigger = stateAvatarTriggers($get['uuid'],$array7A[0],$array7A[1]);
			$xxx++;
			}
		$textA = $arrayS['stateViewFailure'];
		}
		$outputA = $textA;
	$wearing = " is wearing ";
	//$result1 = myquery("SELECT * FROM `".dbprfx."avatar-lex` WHERE `userUUID` = '".$get['uuid']."' LIMIT 1");
	$x = 10;
	$z = 1;
	while ($x > -1) {
	$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'clothing' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	if ($result2 != "not") {
	$xx = 1;
	while($xx <= myrows($result2)) {
	$array2 = myarray($result2);
	
	if((($x == 10)) OR ((isset($LayerThroughCheck[$xx])) and ($LayerThroughCheck[$xx])) OR (!isset($LayerThroughCheck[$xx]))) {
	$result3 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array2['objectUUID']."' AND `stateName` = '".$array2['objectState']."' LIMIT 1");
	
	if ($result3 != "not") {
		$array3 = myarray($result3);
		
		$array4 = splitdata($array3['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($array2['objectUUID'],$get['uuid'],$array5[0],$array5[1]);
		$xxx++;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array3['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
		$text = $array3['stateViewSuccess'];
		}
		else {
			$array6 = splitdata($array3['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array3['stateViewFailure'];
		}
		unset($array6);
		unset($array7);
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
	}
	$array8[$z] = $text;
	$z++;
	unset($array3);
	unset($array4);
	}
	$xx++;
	
	}}
	$x = $x-1;
	}
	$y = $z - 1;
	$x = 1;
		while (isset($array8[$x])) {
			
				
				if ($y == 1){
				$wearing = $wearing.$array8[$x];
				}
				elseif (($y == 2) and ($x == 1)) {
				$wearing = $wearing.$array8[$x]." and ";
				
				}
				elseif(($y == 2) and ($x == 2)) {
				$wearing = $wearing.$array8[$x];
				}
				elseif(($x == 1) and ($y > 2)) {
				$wearing = $wearing.$array8[$x];
				}
				elseif(($x > 1) and ($y > 2) and ($x < $y)) {
				$wearing = $wearing.", ".$array8[$x];
				}
				elseif(($x > 2) and ($y > 2) and ($x == $y)) {
				$wearing = $wearing." and ".$array8[$x];
				}
				elseif($x > $y) {
				}
			
			$x++;
		}
		unset($array8);
		$x = 10;
	$z = 1;
	while ($x > -1) {
	$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'avatar' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	if ($result2 != "not") {
	$xx = 1;
	while($xx <= myrows($result2)) {
	$array2 = myarray($result2);
	
	if((($x == 10)) OR ((isset($LayerThroughCheck[$xx])) and ($LayerThroughCheck[$xx])) OR (!isset($LayerThroughCheck[$xx]))) {
	$result3 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array2['objectUUID']."' AND `stateName` = '".$array2['objectState']."' LIMIT 1");
	
	if ($result3 != "not") {
		$array3 = myarray($result3);
		
		$array4 = splitdata($array3['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($array2['objectUUID'],$get['uuid'],$array5[0],$array5[1]);
		$xxx++;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array3['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
		$text = $array3['stateViewSuccess'];
		}
		else {
			$array6 = splitdata($array3['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array3['stateViewFailure'];
		}
		unset($array6);
		unset($array7);
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
	}
	$array8[$z] = $text;
	$z++;
	unset($array3);
	unset($array4);
	}
	$xx++;
	
	}}
	$x = $x-1;
	}
	$y = $z - 1;
	$x = 1;
		while (isset($array8[$x])) {
			
				
				if ($y == 1){
				$avatar = $avatar.$array8[$x];
				}
				elseif (($y == 2) and ($x == 1)) {
				$avatar = $avatar.$array8[$x]." and ";
				
				}
				elseif(($y == 2) and ($x == 2)) {
				$avatar = $avatar.$array8[$x];
				}
				elseif(($x == 1) and ($y > 2)) {
				$avatar = $avatar.$array8[$x];
				}
				elseif(($x > 1) and ($y > 2) and ($x < $y)) {
				$avatar = $avatar.", ".$array8[$x];
				}
				elseif(($x > 2) and ($y > 2) and ($x == $y)) {
				$avatar = $avatar." and ".$array8[$x];
				}
				elseif($x > $y) {
				}
			
			$x++;
		}
	//$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'avatar' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	
		// $array = myarray($result1);
		if ($wearing != " is wearing ") {
		$wearing = $wearing.".";
		$output = genderBender("woman",$arrayG['gender'])." ".$outputA." ".genderBender("she",$arrayG['gender']).$wearing." ".genderBender("her",$arrayG['gender'])." body displays ".$avatar;
		}
		else {
		$output = genderBender("woman",$arrayG['gender'])." ".$outputA." ".genderBender("she",$arrayG['gender'])." appears to be naked. ".genderBender("her",$arrayG['gender'])." body displays ".$avatar;
		}
		
	}
	if ($get['request'] == "giveObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		if ($result2 != "not") {
		$array = myarray($result2);
		if ($array['copySwitch'] == "yes") {
		$var7 = gen_uuid();
		$output = $get['object']." successfully transferred";
		$str6 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=initObject&uuid=".$get['touuid']."&objectUUID=".$var7."&object=".urlencode($get['object']));
		$result1 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array['objectInstanceUUID']."'");
	$x = 1;
	while($x <= myrows($result1)) {
	$array1 = myarray($result1);
	$result3 = myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$var7."','".$array1[1]."','".$array1[2]."','".$array1[3]."','".$array1[4]."','".$array1[5]."','".$array1[6]."','".$array1[7]."','".$array1[8]."')");
	$x++;
	}
		myquery("INSERT INTO `".dbprfx."inventory` (`objectUUID`,`objectInstanceUUID`,`ownerUUID`,`objectName`) VALUES ('".$array['objectUUID']."','".$var7."','".$get['touuid']."','".myescape(urldecode($get['object']))."')");
		}
		else {
		$output = $get['object']." successfully transferred";
		myquery("UPDATE `".dbprfx."inventory` SET `ownerUUID` = '".$get['touuid']."' WHERE `objectInstanceUUID` = '".$array['objectInstanceUUID']."'");
		myquery("UPDATE `".dbprfx."objects` SET `creatorUUID` = '".$get['touuid']."' WHERE `objectUUID` = '".$array['objectInstanceUUID']."'");
		}
		}
		else {
		$output = $get['object']." could not be transferred";
		}
		
		
	}
	if ($get['request'] == "viewAvatarDetail") {
	$result5 = myquery("SELECT * FROM `".dbprfx."grid-users` WHERE `UUID` = '".$get['uuid']."' LIMIT 1");
	$arrayG = myarray($result5);
	$resultS = myquery("SELECT * FROM `".dbprfx."avatar-states` WHERE `avatarUUID` = '".$get['uuid']."' AND `stateName` = '".$arrayG['avatarState']."' LIMIT 1");
	$arrayS = myarray($resultS);
	$array4A = splitdata($arrayS['statePassThreshold']);
	$xxx = 0;
		
		while(isset($array4A[$xxx])) {
		$array5A = explode("|",$array4A[$xxx]);
		$pass = stateAvatarPassThreshold($get['uuid'],$array5[0],$array5A[1]);
		$xxx=$xxx+2;
		}
		unset($array5A);
		if($pass) {
			$array6A = splitdata($arrayS['statePassTriggers']);
			$xxx = 0;
			while(isset($array6A[$xxx])) {
			$array7A = explode("|",$array6A[$xxx]);
			$trigger = stateAvatarTriggers($get['uuid'],$array7A[0],$array7A[1]);
			$xxx++;
			}
		
		$textA = $arrayS['stateDetailViewSuccess'];
		}
		else {
			$array6A = splitdata($arrayS['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6A[$xxx])) {
			$array7A = explode("|",$array6A[$xxx]);
			$trigger = stateAvatarTriggers($get['uuid'],$array7A[0],$array7A[1]);
			$xxx++;
			}
		$textA = $arrayS['stateDetailViewFailure'];
		}
		$outputA = $textA;
	$wearing = " is wearing ";
	//$result1 = myquery("SELECT * FROM `".dbprfx."avatar-lex` WHERE `userUUID` = '".$get['uuid']."' LIMIT 1");
	$x = 10;
	$z = 1;
	while ($x > -1) {
	$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'clothing' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	if ($result2 != "not") {
	$xx = 1;
	while($xx <= myrows($result2)) {
	$array2 = myarray($result2);
	
	if((($x == 10)) OR ((isset($LayerThroughCheck[$xx])) and ($LayerThroughCheck[$xx])) OR (!isset($LayerThroughCheck[$xx]))) {
	$result3 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array2['objectUUID']."' AND `stateName` = '".$array2['objectState']."' LIMIT 1");
	
	if ($result3 != "not") {
		$array3 = myarray($result3);
		
		$array4 = splitdata($array3['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($array2['objectUUID'],$get['uuid'],$array5[0],$array5[1]);
		$xxx++;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array3['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
		$text = $array3['stateDetailViewSuccess'];
		}
		else {
			$array6 = splitdata($array3['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array3['stateDetailViewFailure'];
		}
		unset($array6);
		unset($array7);
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
	}
	$array8[$z] = $text;
	$z++;
	unset($array3);
	unset($array4);
	}
	$xx++;
	
	}}
	$x = $x-1;
	}
	$y = $z - 1;
	$x = 1;
		while (isset($array8[$x])) {
			
				
				if ($y == 1){
				$wearing = $wearing.$array8[$x];
				}
				elseif (($y == 2) and ($x == 1)) {
				$wearing = $wearing.$array8[$x]." and ";
				
				}
				elseif(($y == 2) and ($x == 2)) {
				$wearing = $wearing.$array8[$x];
				}
				elseif(($x == 1) and ($y > 2)) {
				$wearing = $wearing.$array8[$x];
				}
				elseif(($x > 1) and ($y > 2) and ($x < $y)) {
				$wearing = $wearing.", ".$array8[$x];
				}
				elseif(($x > 2) and ($y > 2) and ($x == $y)) {
				$wearing = $wearing." and ".$array8[$x];
				}
				elseif($x > $y) {
				}
			
			$x++;
		}
		unset($array8);
		$x = 10;
	$z = 1;
	while ($x > -1) {
	$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'avatar' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	if ($result2 != "not") {
	$xx = 1;
	while($xx <= myrows($result2)) {
	$array2 = myarray($result2);
	
	if((($x == 10)) OR ((isset($LayerThroughCheck[$xx])) and ($LayerThroughCheck[$xx])) OR (!isset($LayerThroughCheck[$xx]))) {
	$result3 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array2['objectUUID']."' AND `stateName` = '".$array2['objectState']."' LIMIT 1");
	
	if ($result3 != "not") {
		$array3 = myarray($result3);
		
		$array4 = splitdata($array3['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($array2['objectUUID'],$get['uuid'],$array5[0],$array5[1]);
		$xxx++;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array3['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
		$text = $array3['stateDetailViewSuccess'];
		}
		else {
			$array6 = splitdata($array3['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($array2['objectUUID'],$get['uuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array3['stateDetailViewFailure'];
		}
		unset($array6);
		unset($array7);
		if(preg_match("/(\w|\W)*(LAYER THROUGH)+(\w|\W)*/",$trigger)) {
		$LayerThroughCheck[$xx] = TRUE;
		}
		else {
		$LayerThroughCheck[$xx] = FALSE;
		}
	}
	$array8[$z] = $text;
	$z++;
	unset($array3);
	unset($array4);
	}
	$xx++;
	
	}}
	$x = $x-1;
	}
	$y = $z - 1;
	$x = 1;
		while (isset($array8[$x])) {
			
				
				if ($y == 1){
				$avatar = $avatar.$array8[$x];
				}
				elseif (($y == 2) and ($x == 1)) {
				$avatar = $avatar.$array8[$x]." and ";
				
				}
				elseif(($y == 2) and ($x == 2)) {
				$avatar = $avatar.$array8[$x];
				}
				elseif(($x == 1) and ($y > 2)) {
				$avatar = $avatar.$array8[$x];
				}
				elseif(($x > 1) and ($y > 2) and ($x < $y)) {
				$avatar = $avatar.", ".$array8[$x];
				}
				elseif(($x > 2) and ($y > 2) and ($x == $y)) {
				$avatar = $avatar." and ".$array8[$x];
				}
				elseif($x > $y) {
				}
			
			$x++;
		}
	//$result2 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `creatorUUID` = '".$get['uuid']."' AND `objectTYPE` = 'avatar' AND `worn` = 'YES' and `objectLayer` = '".$x."' ORDER BY `objectOrder` ASC");
	
	
		// $array = myarray($result1);
		if ($wearing != " is wearing ") {
		$wearing = $wearing.".";
		$output = genderBender("woman",$arrayG['gender'])." ".$outputA." ".genderBender("she",$arrayG['gender']).$wearing." ".genderBender("her",$arrayG['gender'])." body displays ".$avatar;
		}
		else {
		$output = genderBender("woman",$arrayG['gender'])." ".$outputA." ".genderBender("she",$arrayG['gender'])." appears to be naked. ".genderBender("her",$arrayG['gender'])." body displays ".$avatar;
		}
		
		
	}
	
	if ($get['request'] == "viewObjectDetail") {
		$result1 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `objectUUID` = '".$get['objectUUID']."'");
		$array = myarray($result1);
		$result2 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$get['objectUUID']."' AND `stateName` = '".$array['objectState']."' LIMIT 1");
		$array2 = myarray($result2);
		$array4 = splitdata($array2['statePassThreshold']);
		
		$xxx = 0;
		
		while(isset($array4[$xxx])) {
		$array5 = explode("|",$array4[$xxx]);
		$pass = statePassThreshold($get['objectUUID'],$get['personuuid'],$array5[0],$array5[1]);
		$xxx++;
		}
		unset($array5);
		if($pass) {
			$array6 = splitdata($array2['statePassTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($get['objectUUID'],$get['personuuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		
		$text = $array2['stateDetailViewSuccess'];
		}
		else {
			$array6 = splitdata($array2['stateFailTriggers']);
			$xxx = 0;
			while(isset($array6[$xxx])) {
			$array7 = explode("|",$array6[$xxx]);
			$trigger = stateTriggers($get['objectUUID'],$get['personuuid'],$array7[0],$array7[1]);
			$xxx++;
			}
		$text = $array2['stateDetailViewFailure'];
		}
		$output = $text;
		
		
		}
	
	if ($get['request'] == "createInventoryObject") {
		
		 
			 $var2 = gen_uuid();
			 $var3 = gen_uuid();
			 $str5 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=DEDUCTxchangeLex&uuid=".$get['editor']."&amount=100");
				if ($str5 != "NSF") {
					$str6 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=initObject&uuid=".$get['editor']."&objectUUID=".$var2."&object=".$get['object']);
					
				 $result1 = myquery("INSERT INTO `".dbprfx."inventory`  (`objectUUID`,`objectInstanceUUID`,`objectName`,`ownerUUID`) VALUES ('".$var2."','".$var2."','".myescape(urldecode($get['object']))."','".$get['editor']."')");
				 file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=updateInventoryObjectLex&uuid=".$var2."&object=".myescape(urlencode($get['object']))."&data=a+blank+object&state=VIEW&personuuid=".$get['editor']);
				 file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=updateInventoryObjectDetailLex&uuid=".$var2."&object=".myescape(urlencode($get['object']))."&data=a+blank+object&state=VIEW&personuuid=".$get['editor']);
				 $output = "Object successfully created.";
				 }
				 else {
				 $output = "Object creation failed; You do not have enough Lexical Points to create a new area.";
				 }
			
		
	 
	
	}
	if ($get['requet'] == "cloneStates") {
	$result1 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$get['uuid']."'");
	$x = 1;
	while($x <= myrows($result1)) {
	$array1 = myarray($result1);
	$result2 = myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$get['touuid']."','".$array1[1]."','".$array1[2]."','".$array1[3]."','".$array1[4]."','".$array1[5]."','".$array1[6]."','".$array1[7]."','".$array1[8]."')");
	$x++;
	}
	$output = "success";
	}
	if ($get['request'] == "updateInventoryObjectLex") {
		$xplode = explode(" ",myescape(urldecode($get['data'])));
		$x=1;
		while(isset($xplode[$x])) {
		$x++;
		}
		$x = $x-1;
		
		$str7 = $get['uuid'];
		$str5 = "PASS";
		if(modYes($str7)) {
		if (DescriptionUpdatesCostMoney) {
		$str5 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=DEDUCTxchangeLex&uuid=".$get['personuuid']."&amount=".$x);
}		
		if (($str5 != "NSF")  or (!DescriptionUpdatesCostMoney)) {
		$resultC = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$str7."' AND `stateName` = '".myescape(urldecode($get['state']))."' LIMIT 1");
		if($resultC != "not") {
		$result1 = myquery("UPDATE `".dbprfx."object-states` SET `".$get['type']."` = '".myescape(urldecode($get['data']))."' WHERE `objectUUID` = '".$str7."' AND `stateName` = '".myescape(urldecode($get['state']))."'");
		}
		else {
		$resultP = myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`".$get['type']."`,`statePassThreshold`,`statePassTriggers`) VALUES ('".$str7."','".myescape(urldecode($get['state']))."','".myescape(urldecode($get['data']))."','AUTO|AUTO','NOTHING|NOTHING')");
		}
		$output = $output."object's view was successfully updated";
		}
		else {
		$output = "Object update failed; You do not have enough Lexical Points to create a new area.";
		}
		}
		else {
		$output = $output."object's view could not be updated;Modify Permission Disabled!";
		}
		
	}
	// DEPRECATED
	/*
	if ($get['request'] == "updateInventoryObjectDetailLex") {
		$xplode = explode(" ",myescape(urldecode($get['data'])));
		$x=1;
		while(isset($xplode[$x])) {
		$x++;
		}
		$x = $x-1;
		
		$str7 = $get['uuid'];
		$str5 = "PASS";
		if(modYes($str7)) {
		if (DescriptionUpdatesCostMoney) {
		$str5 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=DEDUCTxchangeLex&uuid=".$get['personuuid']."&amount=".$x);
}		
		if (($str5 != "NSF")   or (!DescriptionUpdatesCostMoney)) {
		$resultC = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$str7."' AND `stateName` = '".myescape(urldecode($get['state']))."' LIMIT 1");
		if($resultC != "not") {
		$result1 = myquery("UPDATE `".dbprfx."object-states` SET `stateDetailViewSuccess` = '".myescape(urldecode($get['data']))."' WHERE `objectUUID` = '".$str7."' AND `stateName` = '".myescape(urldecode($get['state']))."'");
		}
		else {
		$resultP = myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateDetailViewSuccess`,`statePassThreshold`,`statePassTriggers`) VALUES ('".$str7."','".myescape(urldecode($get['state']))."','".myescape(urldecode($get['data']))."','AUTO|AUTO','NOTHING|NOTHING')");
		}
		$output = $output."object's detail view was successfully updated";
		} 
		else {
		$output = "Object update failed; You do not have enough Lexical Points to create a new area.";
		}
		}
		else {
		$output = $output."object's detail view could not be updated;Modify Permission Disabled!";
		}
		
	}
	*/
	if ($get['request'] == "updateObjectLex") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("UPDATE `".dbprfx."objects` SET `objectLex` = '".myescape(urldecode($get['data']))."' WHERE `objectUUID` = '".$get['uuid']."'");
		$output = $output."success";
		
	}
	if ($get['request'] == "updateObjectType") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("UPDATE `".dbprfx."objects` SET `objectType` = '".myescape(urldecode($get['data']))."' WHERE `objectUUID` = '".$get['uuid']."'");
		$output = $output."success";
		
	}
	if ($get['request'] == "updateObjectDetailLex") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result1 = myquery("UPDATE `".dbprfx."objects` SET `objectDetailLex` = '".myescape(urldecode($get['data']))."' WHERE `objectUUID` = '".$get['uuid']."'");
		$output = $output."success";
		
	}
	if ($get['request'] == "deleteInventory") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result3 = myquery("SELECT * FROM `".dbprfx."inventory`  WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		
		if($result3 != "not") {
		$array3 = myarray($result3);
		$resultR = myquery("UPDATE `".dbprfx."objects` SET `worn` = 'NO' WHERE `objectUUID` = '".$array3['objectInstanceUUID']."'");
		$result1 = myquery("DELETE FROM `".dbprfx."inventory`  WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		$output = $output."successfully deleted";
		}
		else {
		$output = $output."could not be deleted; object not found!";
		}
		
		
	}
	if ($get['request'] == "editAvatarLex") {
		$resultS = myquery("SELECT * FROM `".dbprfx."avatar-states` WHERE `avatarUUID` = '".$get['uuid']."' and `stateName` = '".$get['state']."' LIMIT 1");
		if ($resultS != "not") {
		$result1 = myquery("UPDATE `".dbprfx."avatar-states` SET `".$get['field']."` = '".myescape(urldecode($get['data']))."' WHERE `avatarUUID` = '".$get['uuid']."' and `stateName` = '".$get['state']."'");
		}
		else {
		$result1 = myquery("INSERT INTO `".dbprfx."avatar-states` (`avatarUUID`,`stateName`,`".$get['field']."`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$get['uuid']."','".$get['state']."','".myescape(urldecode($get['data']))."','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
		}
		$output = $output."success";
		
	}
	
	
	if ($get['request'] == "takeObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		if ($result2 != "not") {
		$objectname = myescape(urldecode($get['object'])." copy#".myrows($result2));
		}
		else {
		$objectname = myescape(urldecode($get['object']));
		}
		$result1 = myquery("INSERT INTO `".dbprfx."inventory` (`objectUUID`,`objectInstanceUUID`,`copySwitch`,`modSwitch`,`transferSwitch`,`copyNextSwitch`,`modNextSwitch`,`transferNextSwitch`,`ownerUUID`,`objectName`) values ('".$get['objectUUID']."','".$get['objectInstanceUUID']."','yes','yes','yes','yes','yes','yes','".$get['uuid']."','".$objectname."')");
		if ($result1 != "not") {
		$output = $output."success";
		}
		else {
		$output = $output."fail";
		}
	}
	if ($get['request'] == "inventoryPutObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		if ($result2 != "not") {
		$array = myarray($result2);
		if ($array['copySwitch'] == "yes") {
		$var7 = gen_uuid();
		$output = $array['objectUUID']."~".$var7;
		$str6 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=initObject&uuid=".$get['uuid']."&objectUUID=".$var7."&object=".urlencode($get['object']));
		$result1 = myquery("SELECT * FROM `".dbprfx."object-states` WHERE `objectUUID` = '".$array['objectInstanceUUID']."'");
	$x = 1;
	while($x <= myrows($result1)) {
	$array1 = myarray($result1);
	$result3 = myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$var7."','".$array1[1]."','".$array1[2]."','".$array1[3]."','".$array1[4]."','".$array1[5]."','".$array1[6]."','".$array1[7]."','".$array1[8]."')");
	$x++;
	}
		}
		else {
		$output = $array['objectUUID']."~".$array['objectInstanceUUID'];
		myquery("DELETE FROM `".dbprfx."inventory` WHERE `objectInstanceUUID` = '".$array['objectInstanceUUID']."'");
		}
		}
		else {
		$output = "fail";
		}
		
		
	}
	if ($get['request'] == "wearObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		if ($result2 != "not") {
		$array = myarray($result2);
		$result4 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `objectUUID` = '".$array['objectInstanceUUID']."' LIMIT 1");
		$array2 = myarray($result4);
		$result3 = myquery("UPDATE `".dbprfx."objects` SET `worn` = 'YES',`objectOrder` = '".$get['order']."',`objectLayer` = '".$get['layer']."' WHERE `creatorUUID` = '".$get['uuid']."' and `objectUUID` = '".$array['objectInstanceUUID']."'");
		$output = "Item worn successfully.";
		}
		else {
		$output = "Item could not be worn.";
		}
		
		
	}
	if ($get['request'] == "unwearObject") {
		if (!preg_match("/(\w|\-)+/",$get['uuid'])) { die(); exit(); }
		$result2 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `ownerUUID` = '".$get['uuid']."' AND `objectName` = '".myescape(urldecode($get['object']))."'");
		if ($result2 != "not") {
		$array = myarray($result2);
		$result4 = myquery("SELECT * FROM `".dbprfx."objects` WHERE `objectUUID` = '".$array['objectInstanceUUID']."' LIMIT 1");
		$array2 = myarray($result4);
		$result3 = myquery("UPDATE `".dbprfx."objects` SET `worn` = 'NO' WHERE `creatorUUID` = '".$get['uuid']."' and `objectUUID` = '".$array['objectInstanceUUID']."'");
		$output = "Item taken off successfully.";
		}
		else {
		$output = "Item could not be taken off.";
		}
		
		
	}
	if ($get['request'] == "requestScene")  {
		$str1 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getuser&firstname=".$get['firstname']."&lastname=".$get['lastname']);
		$str2 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=validateuser&uuid=".$str1."&passhash=".$get['pass']);
		if ($str2 == "validated") {
			$str3 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getUserRegionLoc&uuid=".$str1);
			$str4 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getRegionData&uuid=".$str3);
			if ($str4 != "fail") {
				$array1 = explode("~",$str4);
				$regionUUID = $array1[0];
				$regionURL = $array1[3];
				if(preg_match("/(1-9|~)+/",$get['location'])) {
					$array2 = explode("~",$get['location']);
					$localX = $array2[0];
					$localY = $array2[1];
				}
				else {
					$str5 = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=sceneViewDefaultLookup&uuid=".$str3);
					$array2 = explode("~",$str5);
					$localX = $array2[0];
					$localY = $array2[1];
					
				}
				$str5 = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=sceneViewRequest&localX=".$localX."&localY=".$localY."&uuid=".$str3);
				$output = $output.$str5;
			}
		}
	}
	if ($get['request'] == "moveAvatar")  {
	$transtrigger = 2;
		$str1 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getuser&firstname=".$get['firstname']."&lastname=".$get['lastname']);
		$str2 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=validateuser&uuid=".$str1."&passhash=".$get['pass']);
		if ($str2 == "validated") {
			$str3 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getUserRegionLoc&uuid=".$str1);
			$str9 = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getRegionData&uuid=".$str3);
			$array2 = explode("~",$str9);
			$regionUUID = $array2[0];
				$regionURL = $array2[3];
			$str4 = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getLocalLoc&uuid=".$str1);
			if ($str4 != "fail") {
				$array1 = explode("~",$str4);
					$localX = $array1[0];
					$localY = $array1[1];
					if($get['object'] == "north") {
					$localY = $localY + 1;
					}
					elseif($get['object'] == "south") {
					$localY = $localY - 1;
					}
					elseif($get['object'] == "east") {
					$localX = $localX + 1;
					}
					elseif($get['object'] == "west") {
					$localX = $localX - 1;
					} 
					$result[9] = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=verifyLocalCoordinates&uuid=".$str3."&localX=".$localX."&localY=".$localY);
					if($result[9] != "fail") {
					$result[10] = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=putLocalLoc&uuid=".$str3."&localX=".$localX."&localY=".$localY); 
					
					}
					else {
					$output = $output."Scene: You cannot move that direction.";
					$transtrigger = 1;
					}
				}
				if ($transtrigger != 1) {
				$str5 = file_get_contents("http://".$regionURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=sceneViewRequest&localX=".$localX."&localY=".$localY."&uuid=".$str3);
				$output = $output.$str5;
				}
		}
	}
	
return $output;
}
function modYes($uuid) {
		$result1 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `objectInstanceUUID` = '".$uuid."' AND `modSwitch` = 'yes' LIMIT 1");
		if ($result1 != "not") {
		return TRUE;
		}
		else {
		return FALSE;
		}
}
function copyYes($uuid) {
		$result1 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `objectInstanceUUID` = '".$uuid."' AND `copySwitch` = 'yes' LIMIT 1");
		if ($result1 != "not") {
		return TRUE;
		}
		else {
		return FALSE;
		}
}
function transYes($uuid) {
		$result1 = myquery("SELECT * FROM `".dbprfx."inventory` WHERE `objectInstanceUUID` = '".$uuid."' AND `transferSwitch` = 'yes' LIMIT 1");
		if ($result1 != "not") {
		return TRUE;
		}
		else {
		return FALSE;
		}
}
function stateTriggers($obectUUID,$userUUID,$call,$thresh) {
$outcome = TRUE;
if($call == "LAYER THROUGH") {
	if ($thresh == "AUTO") {
	$outcome = "LAYER THROUGH";
	}
}
return $outcome;
}
function statePassThreshold($objectUUID,$userUUID,$call,$thresh) {
$outcome = TRUE;
if($call == "AUTO") {
	if ($thresh == "AUTO") {
	$outcome = TRUE;
	}
}
return $outcome;
}
function stateAvatarTriggers($userUUID,$call,$thresh) {
$outcome = TRUE;
if($call == "LAYER THROUGH") {
	if ($thresh == "AUTO") {
	$outcome = "LAYER THROUGH";
	}
}
return $outcome;
}
function stateAvatarPassThreshold($userUUID,$call,$thresh) {
$outcome = TRUE;
if($call == "AUTO") {
	if ($thresh == "AUTO") {
	$outcome = TRUE;
	}
}
return $outcome;
}
function setStockBody($uuid,$gender) {
if ($gender == "male") {
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."avatar-states` (`avatarUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$uuid."','VIEW','in his mid 30\'s','something you cannot see','in his mid 30\'s','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Skin','VIEW','100','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','rich tanned skin','something you cannot see','rich deeply tanned skin','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Chest','VIEW','120','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','toned pectorals','something you cannot see','attractive toned pectorals','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");

$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Hair','VIEW','110','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','short brown hair','something you cannot see','neatly trimmed short brown hair','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Abs','VIEW','130','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','washboard abs','something you cannot see','a 6 pack of rockhard abs','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Arms','VIEW','140','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','long muscular arms','something you cannot see','long muscular arms','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Sex Organ','VIEW','142','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','a flacid yet impressive penis','something you cannot see','a flaccid yet impressive penis','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");

$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Male Legs','VIEW','150','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','long muscular legs','something you cannot see','long muscular legs','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
}else {
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."avatar-states` (`avatarUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$uuid."','VIEW','in her mid 30\'s','something you cannot see','in hher mid 30\'s','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Skin','VIEW','100','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','rich tanned skin','something you cannot see','rich deeply tanned skin','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Chest','VIEW','120','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','firm round breasts with erect nipples','something you cannot see','firm round breasts with erect nipples','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");

$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Hair','VIEW','110','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','long brown hair','something you cannot see','flowing long brown hair','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Abs','VIEW','130','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','well toned abs','something you cannot see','a 6 pack of well toned abs','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Arms','VIEW','140','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','long slender arms','something you cannot see','long slender arms','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");
$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Sex Organ','VIEW','142','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','a petite vagina with a landing strip of hair','something you cannot see','a petite vagina with a landing strip of hair','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");

$var1 = gen_uuid();
$str1 = $var1;
myquery("INSERT INTO `".dbprfx."objects` (`objectUUID`,`creatorUUID`,`objectTYPE`,`objectName`,`objectState`,`objectOrder`,`objectLayer`,`worn`) VALUES ('".$var1."','".$uuid."','avatar','Female Legs','VIEW','150','0','YES')");
myquery("INSERT INTO `".dbprfx."object-states` (`objectUUID`,`stateName`,`stateViewSuccess`,`stateViewFailure`,`stateDetailViewSuccess`,`stateDetailViewFailure`,`statePassThreshold`,`statePassTriggers`,`stateFailTriggers`) VALUES ('".$str1."','VIEW','long shapely legs','something you cannot see','long shapely legs','something you cannot see','AUTO|AUTO','NOTHING|NOTHING','NOTHING|NOTHING')");

}
return TRUE;
}
?>
